﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.IO;
using System.Globalization;
using System.Xml;
using Elegant2.Business;
using Elegant2.Business.Events;

namespace Elegant
{
    public partial class Ticket : UserControl
    {
        public Ticket()
        {
            InitializeComponent();

        }

        private void btnCarregar_Click(object sender, EventArgs e)
        {
            TicketEventDeclaration ticketEvent = new TicketEventDeclaration();
            ticketEvent.TicketMessage += new TicketMessageEvent(ticketEvent_TicketMessage);

            if (this.tbxAbrir.Text.Trim().Length > 0)
            {
                FacadeBusiness fb = new FacadeBusiness();
                fb.ReadXmlFile(this.tbxAbrir.Text, ticketEvent);
            }
            else
            {
                MessageBox.Show("A seleção do arquivo não foi Realizada");
            }

        }

        void ticketEvent_TicketMessage(object sender, TicketEventArgs e)
        {
            this.lstEstados.Items.Add(e.Message);
        }

        private void btnAbrir_Click(object sender, EventArgs e)
        {
            OpenFileDialog opArquivo = new OpenFileDialog();
            opArquivo.Filter = "*.xml|*.xml|*.txt|*.txt";
            opArquivo.DefaultExt = "*.xml";
            opArquivo.InitialDirectory = Application.StartupPath;
            opArquivo.ShowDialog();
            
            string[] teste = opArquivo.SafeFileNames;
            string c = opArquivo.FileName;

            this.tbxAbrir.Text = c;
        }
       
    }
}
